package com.testing.class2;

import com.testing.web.WebKeyword;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
 * @Classname Job51Test
 * @Description 类型说明
 * @Date 2022/10/7 21:00
 * @Created by 特斯汀Roy
 */
public class Job51Test {
    public static void main(String[] args) {
        WebKeyword web=new WebKeyword();
        web.openBrowser("chrome");
        web.visitWeb("https://www.51job.com/");
        web.inputByCss("#kwdselectid","软件测试");
//        web.submit("#kwdselectid");
        web.click("//button[text()='搜索']");
//        web.getDriver().findElement(By.xpath("//button[text()='搜索']")).click();
        catchJobInfo(web);

        web.halt("5");

        web.closeBrowser();

    }

    private static void catchJobInfo(WebKeyword web) {
        //获取所有岗位的名称和薪资
        List<WebElement> job = web.getDriver().findElements(By.xpath("//div[@class='j_joblist']/div[@class='e']//p[@class='t']/span[@title]"));

        List<WebElement> salary = web.getDriver().findElements(By.xpath("//div[@class='j_joblist']/div[@class='e']//span[@class='sal']"));
        for (int index = 0; index < job.size(); index++) {
            //get从list中取出数据，他们是元素。
//            System.out.println(job.get(index));
//            System.out.println(salary.get(index));
            System.out.println(job.get(index).getText()+"职位的薪资是："+salary.get(index).getText());

        }
    }
}
